﻿<UserControl xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"  xmlns:my="clr-namespace:uTorrentSL.Views"  x:Class="uTorrentSL.Views.FiltersView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:cx="clr-namespace:uTorrentSL.Behaviors"
             xmlns:cv="clr-namespace:uTorrentSL.Converters"
             xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
             
             mc:Ignorable="d"
             d:DesignWidth="500"
             DataContext="{Binding FiltersViewModel, Source={StaticResource Locator}}">
    <UserControl.Resources>
        <Style x:Key="ListBoxItemStyle1" TargetType="ListBoxItem">
            <Setter Property="Padding" Value="3"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Grid.ColumnSpan="2" Margin="0,0,50,0">
            <HyperlinkButton HorizontalAlignment="Right" Style="{StaticResource LinkStyle}" MinHeight="0" MinWidth="0" Padding="0,0,5,0" FontSize="18" Content="+ new" Margin="0,0,0,0">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding LaunchModalCommand, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="AddFilter" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </HyperlinkButton>
        </Grid>
        <ListBox x:Name="lbFilters" Grid.Row="1" SelectedItem="{Binding SelectedFilter, Mode=TwoWay}" ItemsSource="{Binding Path=Data.Filters}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Border Canvas.ZIndex="10" Background="Transparent">
                            <i:Interaction.Triggers>
                                <cx:DoubleClickTrigger>
                                    <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding FiltersViewModel.SelectCommand, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="{Binding ElementName=lbFilters, Path=SelectedItem}"/>
                                </cx:DoubleClickTrigger>
                            </i:Interaction.Triggers>
                        </Border>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding Name}" Margin="0,0,20,0" Grid.Column="0" VerticalAlignment="Top" />
                            <TextBlock Text="{Binding FilterText}" Foreground="Gray" Margin="0,0,0,0" Grid.Column="1" VerticalAlignment="Top" />
                        </Grid>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>
